<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    
    class Role_m extends CI_Model {
        public function __construct() {
            #$this->load->database();
        }
        
        function get_all_role() {
            $query = $this->db->get('role');
            return $query->result_array();
        }
        
        function get_all_roles() {       
            $this->db->select('role_id, rolename');
            $query = $this->db->get('role');
            return $query->result();
        }
        
        function get_role_id($role_name) {             
            $this->db->select('role_id');
            $this->db->from('role');
            $this->db->where('rolename', $role_name);

            $query = $this->db->get();

            return $query->row();
        }
        
        function get_role_item ($name) {
            $replace_name =  str_replace("_", " ", $name); 
            $this->db->where('rolename', $replace_name);
            $query = $this->db->get('role');
            return $query->row_array();
        }
    }
?>
